from rest_framework .serializers import Serializer
from rest_framework import serializers

from drfapp.models import BOOK,Hero





class HeroRelated(serializers.ModelSerializer):
    class Meta:
        model=Hero
        fields='__all__'


class BOOKSerializer(serializers.ModelSerializer):
    hero=HeroRelated(read_only=True,many=True)
    class Meta:
        model=BOOK
        fields='__all__'


class BOOKRelated(serializers.ModelSerializer):
    class Meta:
        model=BOOK
        fields='__all__'


class HeroSerializer(serializers.ModelSerializer):
    hbook=BOOKRelated(read_only=True)
    hbook_id = serializers.IntegerField()
    class Meta:
        model=Hero
        fields='__all__'




